#!/bin/bash

#
# Set CPU performance scalling
#

. /etc/init.d/functions.sh

scaling_factor=${1}
ebegin "Setting CPU scalling factor to: ${scaling_factor}"

case "${scaling_factor}" in
"performance")
	[ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] && echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
	[ -f /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor ] && echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
	[ -f /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor ] && echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
	[ -f /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor ] && echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
;;
*)
	[ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
	[ -f /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
	[ -f /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
	[ -f /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
;;
esac
eend $?
